
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

using namespace std;

int main()
{
  close(1);
  int fd = open("my_ls.txt", O_WRONLY | O_TRUNC | O_CREAT, 0666);
  if (fd < 0)
  {
    cout << "fail open" << endl;
    exit(-1);
  }

  printf("hello linux\n");
  close(fd);
  return 0;
}

